<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>训练员管理</title>
<%@ include file="/common/include.jsp" %>
<script>
function salemancheck(){}
function closePicture(){}

$(function(){
	$("#gridTable").jqGrid({
		datatype: "json",
		url:contextPath+'/leader/list',
		prmNames : {search : "search"}, 
	    colNames:["id","姓名", "注册时间", "性别 ", "级别", "系统账号", "状态", "操作"],
	    colModel:[
	    	{name:'id',index:'id', width:30, sorttype:"string",align:"center", hidden:true},
	    	{name:'name',index:'name', width:130,sorttype:"string",align:"center"},
	    	{name:'registerTime',index:'registerTime', width:130,sorttype:"string",align:"center"},
	       	{name:'sex',index:'sex', width:100,sorttype:"string",align:"center",formatter:function(cellvalue, options, rowObject){
				return ((rowObject.sex ==1)?"男":"女");}},
			{name:'level',index:'level', width:100,sorttype:"string",align:"center",
				formatter:function(cellvalue, options, rowObject){
					if (cellvalue == 1){return "士官";}
					else if (cellvalue == 2){return "少尉";}
					else if (cellvalue == 3){return "中尉";}
					else if (cellvalue == 4){return "上尉";}
					else return cellvalue;
				}
			},
			{name:'user.name',index:'user.name', width:101,sortable:false,align:"center"},
			{name:'status',index:'status', width:100,sorttype:"string",align:"center",formatter:function(cellvalue, options, rowObject){
				if (cellvalue == 0){return "无效";}
				else if (cellvalue == 1){return "在职";}
				else if (cellvalue == 2){return "已离职";}
				else if (cellvalue == 3){return "暂停职务";}
				else return cellvalue;
			}},
	        {name:'option',index:'options', width:168,sortable:false,align:"center",formatter:function(cellvalue, options, rowObject){
				return '<A href="'+contextPath+'/leader/edit/'+rowObject.id+'">修改</A>&nbsp;&nbsp;|&nbsp;&nbsp;'
					+'<A href="'+contextPath+'/leader/setUserPage/'+rowObject.id+'">设置账号</A>'
					+'&nbsp;|&nbsp;<a href="javascript:void(0);" onclick="copyorder(\'' + rowObject.odcd + '\',\'' + rowObject.odnm + '\');">删除</a>&nbsp;';
				}
			}                
		],
	    sortname:'id',
	    sortorder:'desc',
	    viewrecords:true,
		rowNum:15,
		height: 'auto',
		width: 799,
		page:1,
	    rowList:[10,15,30,60],
		multiselect: true,
		scrollrows: true,
		pager:"#gridPager" ,
		jsonReader:{repeatitems : false},
		gridComplete: function(){}
	});
	
	jQuery("#gridTable").jqGrid('navGrid','#gridPager',{edit:false,add:false,del:false,search:false,refresh:false});
	jQuery.fn.center = function(){   
			this.css("position","absolute");   
			this.css("top", ( ($(window).height() - this.height() ) / 2+$(window).scrollTop()) + "px");   
			this.css("left", (( $(window).width() - this.width() ) / 2+$(window).scrollLeft()) + "px");   
			return this;   
	};
			
				
	jQuery("#gridTable").navGrid('#gridPager',{edit:false,add:false,del:false,search:false,refresh:false}).navButtonAdd('#gridPager',{   
				caption:"删除",    
				onClickButton: function()
					{    
					var selected_odid=jQuery("#gridTable").jqGrid('getGridParam','selarrrow');
					var odcds=selected_odid.join('@');
					if (selected_odid != '') {
						for ( var i = 0; i < selected_odid.length; i++) {
							if (selected_odid[i] != undefined && selected_odid[i] != "") {
								var ret = jQuery('#gridTable').jqGrid('getRowData',selected_odid[i]);
								if (ret.status == '已提交') {
									alert("已提交订单不能删除！");
									return false;
								}
							}
						}
						}
						if(odcds!=""){
                         var question=confirm("确认删除所选广告吗？");
						 if(question )
						 {					
					$.ajax({
					    'url': contextPath+'/order/order.delete.do',
					    'data': 'odcds='+odcds+'&date='+new Date(),
					    	
					    'dataType': 'text',
					    'type': 'POST',
					    success: function( flag )
					    {
					    	if ( parseInt(flag)>0 )
					    	{
					    		$("#modifypic").center();  
								$('#modifypic').fadeIn(200);
								$('#modifypic').fadeOut(600);
								showPicture();
					    		var curPage = $("#jqgrid").jqGrid("getGridParam", "page");
					    		$("#gridTable").jqGrid("setGridParam",{page:curPage}).trigger("reloadGrid");;
					    	}
					    	else
					    	{
					    	     alert("删除失败，请重新阐述或者联系管理员！");
					    	}
						}
				      		,'complete': function(){closePicture();}
					});
						}
						else
						{
							return false;
						} 
					}
					   else
					   {
							alert("请选择广告");
					   }
					},    
				position:"frist"  
			});
	        jQuery("#gridTable").navGrid('#gridPager',{edit:false,add:false,del:false,search:false,refresh:false}).navButtonAdd('#gridPager',{   
				caption:"提交",    
				onClickButton: function()
					{    
					var selected_odid=jQuery("#gridTable").jqGrid('getGridParam','selarrrow');
					var odcds=selected_odid.join('@');
					if (selected_odid != '') {
						for ( var i = 0; i < selected_odid.length; i++) {
							if (selected_odid[i] != undefined) {
								var ret = jQuery('#gridTable').jqGrid('getRowData',selected_odid[i]);
								if (ret.status == '已提交') {
									alert("请不要再次提交已提交订单！");
									return false;
								}
							}
						}
						}
						if(odcds!=""){
                         var question=confirm("确认提交吗？");
						 if(question )
						 {					
						$.ajax({
					    'url': contextPath+'/order/order.commit.do',
					    'data': 'odcds='+odcds+'&date='+new Date(),
					    'dataType': 'text',
					    'type': 'POST',
					    success: function( flag )
					    {
					    	if ( parseInt(flag)>0 )
					    	{
					    		$("#commitpic").center();  
								$('#commitpic').fadeIn(200);
								$('#commitpic').fadeOut(600);
								showPicture();
					    		var curPage = $("#jqgrid").jqGrid("getGridParam", "page");
					    		$("#gridTable").jqGrid("setGridParam",{page:curPage}).trigger("reloadGrid");;
					    	}
					    	else
					    	{
					    	     alert("提交失败，请重新阐述或者联系管理员！");
					    	}
						},'complete': function(){closePicture();}
					});
						}
						else
						{
							return false;
						} 
					}
					   else
					   {
							alert("请选择订单");
					   }
					},    
				position:"frist"  
			});		
						
						jQuery("#search_cd").keydown(function(e)
							{
		
								if(e.keyCode==13)
									{  
										gridReload();
									}  
							}); 
							 $('#search_cd').focus(function()
							{     
		                            var txt_value= $(this).val();
					                if(txt_value==this.defaultValue){
						       $(this).val("");					
						       $(this).attr('class',"ss_inp1");
					}

								
							});
	                              $('#search_cd').blur(function()
							{

					var txt_value= $(this).val();
					if(txt_value==""){
						$(this).attr('class',"ss_inp");
						$(this).val(this.defaultValue);
	                                      
					}
							});
							  if($("#search_cd").val() == '输入订单名称关键字' ){
	                                            $('#search_cd').attr('class',"ss_inp");
	                                          }
		});
		
function copyorder(odcd,odnm){
	 var name=prompt("请输入订单名称","");
	 if (name!=null && name!="") {
		 $.ajax({
			    'url': contextPath+'/leader/list',
			    'data': {"odcd" : odcd, "odnm" : name},
			    'dataType': 'text',
			    'type': 'POST',
			    success: function( flag )
			    {
			    	if ( parseInt(flag)>0 )
			    	{
			    		$("#copypic").center();  
						$('#copypic').fadeIn(200);
						$('#copypic').fadeOut(600);
						showPicture();
			    		var curPage = $("#jqgrid").jqGrid("getGridParam", "page");
			    		$("#gridTable").jqGrid("setGridParam",{page:curPage}).trigger("reloadGrid");;
			    	}
			    	else
			    	{
			    	     alert("复制失败，请重新阐述或者联系管理员！");
			    	}
				}
		      	,'complete': function(){closePicture();}
			});
	 }else {
		 alert("订单名称不能为空");
	 }
}
		
		function gridReload(){
		var cd_mask = htmlspecialchars(jQuery("#search_cd").val());
		if(cd_mask=='输入订单名称关键字')cd_mask='';
		if(cd_mask=='')
		{
			$('#keyword').html('');
		}
		else
		{
		$('#keyword').html(' > 关于"'+cd_mask+'"的搜索结果');
		}
		
		var slotstatus=jQuery("#slotstatuslist").val();
		var postData = $("#gridTable").jqGrid("getGridParam", "postData");  //查询出原来的值
	    var searchURL = {"odnm":cd_mask,"slotstatus":slotstatus}; //现在的值
	    $.extend(postData, searchURL);  //替换
	    
		jQuery("#gridTable").jqGrid("setGridParam",{
							postData : postData,
							page : 1
						}).trigger("reloadGrid");
		

	}
	function checkboxchange()
		{
			var s;
			
			s = jQuery("#gridTable").jqGrid('getGridParam','selarrrow');
			if(s[0]==undefined)	{s.shift();	}
		
			if(s!=''){$('#openoption').show();$('#openoption1').hide();}//显示
				 else{$('#openoption').hide();$('#openoption1').show();}//隐藏
				 
			
		}
	function headcheckboxchange()
		{
			if($('#cb_gridTable').attr('checked')==false)$('#openoption1').show();$('#openoption').hide();
		
		}
	</script>
</head>
<body>
<div style="z-index: 999; width: 150px; display: none" id=modifypic class=succ_box>
		<div class=succ_l>删除成功! </div>
		<div class=succ_r></div>
	</div>
<div style="z-index: 999; width: 150px; display: none" id=copypic class=succ_box>
		<div class=succ_l>复制成功! </div>
		<div class=succ_r></div>
	</div>
<div style="z-index: 999; width: 150px; display: none" id=commitpic class=succ_box>
		<div class=succ_l>提交成功! </div>
		<div class=succ_r></div>
	</div>
<div class=wrapper>
	<jsp:include page="/common/header.jsp"><jsp:param value="2" name="nav"/></jsp:include>
	<div class=content>
		<div class=col_l>
			<div class=l_top></div>
			<div class=l_menu>
				<jsp:include page="/common/l_info_place.jsp">
					<jsp:param value="2" name="nav" />
				</jsp:include>
			</div>
			<div class=l_bottom></div>
		</div>
		<div class=col_r>
			<div class="guide blue">
				<SPAN class=left>当前位置：训练员管理 </SPAN>
				<SPAN class=right>
					<input id="search_cd" class="ss_inp" value="输入姓名关键字" type="text" name="textfield">
					<input onClick="gridReload();" value="提交" src="${pageContext.request.contextPath}/images/search.png" type="image" name="Submit">
				</SPAN>
			</DIV>
			<DIV class=top_title>
				<DIV class=tab_l></DIV>
				<DIV class=tab_c>
					<UL>
						<LI class="f12_b">训练员</LI>
						<LI id="ordercreateli" class="right mar7">
							<A href="${pageContext.request.contextPath}/page/leaderAdd.jsp"><img src="${pageContext.request.contextPath}/images/cj_order.gif"></A>
						</LI>
					</UL>
				</DIV>
				<DIV class=tab_r></DIV>
			</DIV>
			<TABLE id=gridTable class=blue>
			</TABLE>
			<DIV id=gridPager></DIV>
		</DIV>
		<DIV class=clear></DIV>
	</DIV>
	<DIV class=footer>CopyRight &copy;Research Institute of Computer Systems of SCUT. All Rights Reserved</DIV>
</DIV>
<!--  帮助小提示  -->
<INPUT value=am1.adm.cnzz.net type=hidden>
<INPUT 
id=uidlog value=83198 type=hidden>
<SCRIPT>
function showHelp(obj){
var help = document.getElementById("key"+obj).style.display;
document.getElementById("key"+obj).style.display="";

} 

function closeHelp(obj){
var help = document.getElementById("key"+obj).style.display;
document.getElementById("key"+obj).style.display="none";
}
			if('0'=='0')
				{
					if(1==0)
				{
						$.ajax({
						type:'POST',
						url:'?mo=manager&fo=warning&ro=s&sid=57178&pid=83198',
						data:'date='+new Date(),
						async:false,
						success:function(msg)
						{
							if(msg==-1)
							{
								$('#web_site').remove();
							}
							else
							{
							if(msg==0)	
								{
									$('#warningnum').attr('color','green');
									$('#warningnum').html(0);
								}
							if(msg>0)
								{
								
									$('#warningnum').html("<a href='?mo=slot&fo=slot_paiqi&warn=yes&ro=s&sid=57178&pid=83198' style='color:red;'>"+msg+"</a>");
									
								}
							}				
						}
						});
								
					}
					}
	</script>
</body>
</html>